'''
    任务：将苏宁，国美，搜索一个商品，点击详情，点击添加购物车，流程开发出来。

'''



from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import time
driver = webdriver.Chrome()

driver.maximize_window()
driver.get(r"F:\super_hongruan\页面转换\登陆和注册\register.html")
time.sleep(1)
driver.find_element_by_id("username").send_keys("jason")
time.sleep(1)
driver.find_element_by_xpath("//*[@id='password']").send_keys("admin")
time.sleep(1)
driver.find_element_by_xpath("//*[@id='surePassword']").send_keys("admin")
time.sleep(1)
# 下拉选项
driver.find_element_by_xpath("//*[@id='userType']").send_keys("普通类型")
time.sleep(1)


#  性别
driver.find_element_by_xpath("//*[@value='girl']").click()
time.sleep(1)
# 爱好
driver.find_element_by_xpath("//*[@value='sport']").click()
driver.find_element_by_xpath("//*[@value='music']").click()

# 邮件
driver.find_element_by_xpath("//input[@type='email']").send_keys("135a@qq.com")
time.sleep(1)
# 自我介绍
driver.find_element_by_xpath("//*[@id='introduceText']").send_keys("我是高级测试工程师")

time.sleep(1)
# 点击提交
driver.find_element_by_xpath("//*[@id='submit']").click()
time.sleep(1)
# 点击确定
driver.find_element_by_xpath('//*[@id="layui-layer1"]/div[3]/a[1]').click()

########################################登陆
time.sleep(1)
driver.find_element_by_xpath("//*[@id='userNname']").send_keys("jason")
time.sleep(1)
driver.find_element_by_xpath("//*[@id='password']").send_keys("admin")

# ActionChains 事件链对象

ac = ActionChains(driver)
time.sleep(1)
# 获取滑块
ele = driver.find_element_by_xpath('//*[@id="box"]/div[3]')
time.sleep(1)
ac.click_and_hold(ele).move_by_offset(300,0).perform() # 立即执行

ac.release() # 释放鼠标

# 点击登陆
driver.find_element_by_xpath("//*[@id='submit']").click()
time.sleep(1)
driver.find_element_by_xpath('//*[@id="layui-layer2"]/div[3]/a').click()

time.sleep(2)

driver.quit()
















